package com.jn.exam.ucenter.schedule;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.jn.exam.DateTimeUtil;
import com.jn.exam.ucenter.entity.Student;
import com.jn.exam.ucenter.entity.Teacher;
import com.jn.exam.ucenter.service.StudentService;
import com.jn.exam.ucenter.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.TimeUnit;

/**
 * @author 江南大学1033190417
 * @date 2022/1/20 14:42
 * <p>
 * 定时任务的类
 */
@Component
@Slf4j
public class ScheduledTask {

    @Autowired
    private StudentService studentService;

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    /*
    在线生成cron表达式
      https://qqe2.com/cron
     */

    //每隔五秒执行该方法
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void task1() {
//        System.out.println("***********task1执行了");
//    }

    //每天凌晨一点执行
    //重置所有用户登录状态
    @Scheduled(cron = "0 0 1 * * ? ")
    @Transactional
    public void task2() {

    }
}
